﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DEMO3.DTO;
using System.Data.SqlClient;

namespace DEMO3.DAO
{
    class PhongChieuDAO
    {
        public DataTable Get()
        {
            DataProvider test = new DataProvider();
            return test.ExcuteQuery("GET_PHONGCHIEU", null);
        }

        public bool Add(PhongChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[6];
            arrpara[0] = new SqlParameter("SoGheToiDa", dto.SoGhe);
            arrpara[1] = new SqlParameter("DayGheToiDa", dto.SoDay);
            arrpara[2] = new SqlParameter("MoTa", dto.MoTa);
            arrpara[3] = new SqlParameter("DieuKienKiThuat", dto.DKKiThuat);
            arrpara[4] = new SqlParameter("MaRap", dto.MaRap);
            arrpara[5] = new SqlParameter("TrangThai", dto.TrangThai);
            return test.ExcuteNonQuery("ADD_PHONGCHIEU", arrpara);
        }
        public bool Delete(PhongChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[1];
            arrpara[0] = new SqlParameter("MaPhong", dto.MaPhong);
            return test.ExcuteNonQuery("DELETE_PHONGCHIEU", arrpara);
        }
        public bool Update(PhongChieuDTO dto)
        {
            DataProvider test = new DataProvider();
            SqlParameter[] arrpara = new SqlParameter[7];
            arrpara[0] = new SqlParameter("MaPhong", dto.MaPhong);
            arrpara[1] = new SqlParameter("SoGheToiDa", dto.SoGhe);
            arrpara[2] = new SqlParameter("DayGheToiDa", dto.SoDay);
            arrpara[3] = new SqlParameter("MoTa", dto.MoTa);
            arrpara[4] = new SqlParameter("DieuKienKiThuat", dto.DKKiThuat);
            arrpara[5] = new SqlParameter("MaRap", dto.MaRap);
            arrpara[6] = new SqlParameter("TrangThai", dto.TrangThai);
            return test.ExcuteNonQuery("UPDATE_PHONGCHIEU", arrpara);
        }
    }
}
